package com.yan.switchtest;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        // 定义两个整数的变量
        int num1, num2;
        // 键盘输入
        Scanner input = new Scanner(System.in);
        System.out.println("请输入第一个整数");
        num1 = input.nextInt();
        System.out.println("请输入第二个整数");
        num2 = input.nextInt();
        // 定义运算变量
        int operation;
        // 使用switch判断
        System.out.println("请输入您要进行的运算(1:表示加法,2:表示减法,3:表示乘法,4:表示除法");
        operation = input.nextInt();
        switch (operation) {
            case 1:
                System.out.println(num1 + "+" + num2 + "=" + (num1 + num2));
                break;
            case 2:
                System.out.println(num1 + "-" + num2 + "=" + (num1 - num2));
                break;
            case 3:
                System.out.println(num1 + "*" + num2 + "=" + (num1 * num2));
                break;
            case 4:
                System.out.println(num1 + "/" + num2 + "=" + (num1 * 1.0 / num2));
        }
    }
}
